/**
 * Created date: 24/04/2011
 * Java script
 */
function onSelectNationalPhoneCodeChange(idSrc, idDes) {
	var src = document.getElementById(idSrc);
	var des = document.getElementById(idDes);
	des.value = src.value;
}

function isLeapYear(year) {
	if((year%4==0 && year%100!=0)||(year%400==0)) {
		return true;
	}
	return false;
}

function checkValidDate(idDay, idMonth, idYear, error_message) {
	var day = parseInt(document.getElementById(idDay).value);
	var month = parseInt(document.getElementById(idMonth).value);
	var year = parseInt(document.getElementById(idYear).value);
	switch(month) {
	case 4:
	case 6:
	case 9:
	case 11:
		if(day>30) {
			alert(error_message);
			return false;
		}
		break;
	case 2:
		if(isLeapYear(year)) {
			if(day>29) {
				alert(error_message);
				return false;
			}
		} else {
			if(day>28) {
				alert(error_message);
				return false;
			}
		}
		break;
	}
	
	return true;
}

function checkConfirmPassword(idInputPass, idConfirmPass, not_match_message) {
	var pass = document.getElementById(idInputPass).value;
	var confirm = document.getElementById(idConfirmPass).value;
	if(pass.equal(confirm)) {
		return true;
	}
	alert(not_match_message);
	return false;
}

function checkValidData(idDay, idMonth, idYear, error_message) {
	if(checkValidDate(idDay, idMonth, idYear, error_message)){
		return false;
	}
}

var curDt = new Date(new Date().getFullYear()-15,1,1);
function disableDate(day) {
	if(day.isWeekend) return false;
	
	if(curDt==undefined) {
		curDt = day.date.getDate;
	}
	
	if(curDt.getTime() - day.date.getTime() > 0) {
		return true;
	} else {
		return false;
	}
}
function disabledClassesProv(day) {
	if(curDt.getTime() - day.date.getTime() <0 ) {
		return 'rich-calendar-boundary-dates';
	}
}